<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>DHTML Tree samples. dhtmlXTree Pro - Context menu and complex drag-and-drop</title>
</head>
<style>
	body {font-size:12px; }
	.{font-family:arial;font-size:12px}
	h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
</style>
<body>
	<h1>Context menu and complex drag-and-drop</h1>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<link rel="STYLESHEET" type="text/css" href="menu/css/dhtmlXMenu.css">
	<link rel="STYLESHEET" type="text/css" href="menu/css/Context.css">
	<script  src="../js/dhtmlXCommon.js"></script>
	<script  src="../js/dhtmlXTree.js"></script>
	<script language="JavaScript" src="menu/js/dhtmlXProtobar.js"></script>
	<script language="JavaScript" src="menu/js/dhtmlXMenuBar.js"></script>
	<script language="JavaScript" src="menu/js/dhtmlXMenuBar_cp.js"></script>
	<script language="JavaScript" src="menu/js/dhtmlXCommon.js"></script>
Right click on tree node.
Drag and drop tree items within one tree or between trees.
Complex drag-n-drop allows you to reorder tree nodes within one level and at the same time supports drop as child behavior.
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" style="width:260; height:260;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
			</td>
			<td valign="top">
				<div id="treeboxbox_tree2" style="width:260; height:260;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
			</td>
		</tr>
		<tr>
			<td></td>
		</tr>
	</table>
<hr>
<XMP>
<div id="treeboxbox_tree" style="width:200;height:200"></div>
<script>
	//init menu
			aMenu=new dhtmlXContextMenuObject('120',0,"Demo menu");
			aMenu.menu.setGfxPath("../imgs/");		
			aMenu.menu.loadXML("menu/_context.xml");				
			aMenu.setContextMenuHandler(onButtonClick);

	//init tree
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.enableDragAndDrop(true);
			tree.enableContextMenu(aMenu); //link context menu to tree
			tree.loadXML("tree3.xml")
				
</script>
</XMP>
	<script>
			function onButtonClick(menuitemId,treeitemId)
			{
				tree.setItemColor(treeitemId,menuitemId.split("_")[1],menuitemId.split("_")[1]);
			}
			function onButtonClick2(menuitemId,treeitemId)
			{
				tree2.setItemColor(treeitemId,menuitemId.split("_")[1],menuitemId.split("_")[1]);
			}

			aMenu=new dhtmlXContextMenuObject('120',0,"Demo menu");
			aMenu.menu.setGfxPath("../imgs/");
			aMenu.menu.loadXML("menu/_context.xml");
			aMenu.setContextMenuHandler(onButtonClick);

			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.enableDragAndDrop(true);
			tree.enableContextMenu(aMenu);
            tree.enableSmartXMLParsing(true);
            tree.setDragBehavior("complex");
			tree.loadXML("tree.xml")


			aMenu2=new dhtmlXContextMenuObject('120',0,"Demo menu");
			aMenu2.menu.setGfxPath("../imgs/");
			aMenu2.menu.loadXML("menu/_context.xml");
			aMenu2.setContextMenuHandler(onButtonClick2);

			tree2=new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0);
			tree2.setImagePath("../imgs/");
			tree2.enableDragAndDrop(true);
		    tree2.enableContextMenu(aMenu2);
            tree2.setDragBehavior("complex");
			tree2.loadXML("tree.xml")




	</script>
<br><br>

</body>
</html>
